package com.css.upms.api.dto;

import com.css.common.core.utils.tree.TreeNode;
import com.css.upms.api.entity.SysMenu;
import com.css.upms.api.vo.MenuVo;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * MenuTree
 * 菜单树
 *
 * @author hanyx
 * @date 2019/05/03
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class MenuTree extends TreeNode {
    private String icon;
    private String title;
    private String name;
    private boolean spread = false;
    private String url;
    private String component;
    private String authority;
    private String redirect;
    private String permission;
    private String type;
    private String label;
    private Integer sort;
    private boolean vis;

    public MenuTree() {
    }

    public MenuTree(String id, String name, String parentId) {
        this.id = id;
        this.parentId = parentId;
        this.name = name;
        this.label = name;
    }

    public MenuTree(String id, String name, MenuTree parent) {
        this.id = id;
        this.parentId = parent.getId();
        this.name = name;
        this.label = name;
    }

    public MenuTree(MenuVo menuVo) {
        this.id = menuVo.getMenuId();
        this.parentId = menuVo.getParentId();
        this.title = menuVo.getMenuName();
        this.icon = menuVo.getIcon();
        this.name = menuVo.getMenuName();
        this.url = menuVo.getUrl();
        this.component = menuVo.getComponent();
        this.type = menuVo.getMenuType();
        this.label = menuVo.getMenuName();
        this.sort = menuVo.getOrderNum();
        this.vis = menuVo.getVis() == 1 ? true : false;
    }

    public MenuTree(SysMenu menuVo) {
        this.id = menuVo.getMenuId();
        this.parentId = menuVo.getParentId();
        this.title = menuVo.getMenuName();
        this.icon = menuVo.getIcon();
        this.name = menuVo.getMenuName();
        this.url = menuVo.getUrl();
        this.component = menuVo.getComponent();
        this.type = menuVo.getMenuType();
        this.label = menuVo.getMenuName();
        this.sort = menuVo.getOrderNum();

    }

}
